import 'package:app_core/app_core.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:yh_core_flutter_project/project/common/channels/navigation_channel.dart';
import 'package:yh_core_flutter_project/project/common/utils/project_interface.dart';
import '../project/common/managers/language_manager.dart';
import '../project/common/managers/theme_manager/theme_manager.dart';
import '../project/common/managers/user_manager.dart';
import '../project/common/channels/data_channel.dart';

/// 应用启动初始化
class AppStartUp {
  static Future<void> initialize() async {
    try {
      /// 1. 初始化 SharedPreferences (必须在 UserManager 之前)
      await SharedPUtil.init();

      /// 2.给core层有接受project层能力
      CoreInterfaceManager.init(ProjectInterface());

      /// 3. 初始化管理器
      _initManagers();

      /// 4.初始化第三方服务
      _initService();
    } catch (e, stack) {
      YHLog.e('❌ 应用启动初始化失败: $e,错误堆栈: $stack');
      rethrow;
    }
  }

  ///初始化全局单利
  static void _initManagers() {
    Get.put(LanguageManager(), permanent: true);

    Get.put(ThemeManager(), permanent: true);

    Get.put(UserManager(), permanent: true);
  }

  ///初始化服务 TODO
  static void _initService() {
    ///其他SDK服务
  }
}
